<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 输入：[1, 2, 2, 3, 4, 2, 2], 2
      // 输出：[1, 3, 4]
      let item = 2;
      var arr = [1, 2, 2, 3, 4, 2, 2];
      function removeWithoutCopy(arr, item) {
        var arr = [1, 2, 3, 4, 2];
        for (var i = 0; i < arr.length; i++) {
          if (arr[i] == item) {
            arr.splice(i, 1);
          }
        }
        console.log(arr);
      }
      removeWithoutCopy(arr, item);
    </script>
  </body>
</html>
